﻿using System.Windows;
using System.Windows.Input;

namespace MediaBrowser.CustomControls.MouseCursors
{
    public class CursorSet
    {
        public static Cursor GetCursor(DependencyObject d)
        {
            return (Cursor)d.GetValue(CursorProperty);
        }

        public static void SetCursor(DependencyObject d, Cursor c)
        {
            d.SetValue(CursorProperty, c);
        }

        public static DependencyProperty CursorProperty =
        DependencyProperty.RegisterAttached("Cursor", typeof(Cursor), typeof(CursorSet),
        new PropertyMetadata(new PropertyChangedCallback(OnCursorPropertyChanged)));


        static void OnCursorPropertyChanged(DependencyObject d,
              DependencyPropertyChangedEventArgs e)
        {
            FrameworkElement element = d as FrameworkElement;
            Cursor c = e.NewValue as Cursor;
            element.Cursor = CustomMouseCursors.GetCursor(c); ;
        }
    }
}
